<template>
	<view class="content">
		<u--form labelPosition="left" :model="form" :rules="rules" ref="form">
			
			<u-form-item label="用户名"	prop="username"	borderBottom	ref="item1">
				<u--input v-model="form.username" border="none"></u--input>
			</u-form-item>
			
			<u-form-item label="密码"	prop="password"	borderBottom	ref="item1">
				<u--input v-model="form.password" border="none"></u--input>
			</u-form-item>
		
		</u--form>
		
		
		<u-button text="登录" @click="login"></u-button>
		
	</view>
</template>

<script>
import {login } from '@/api/login.js';
export default {
	data() {
		return {
			form:{
				username:'admin',
				password:'admin123'
			},
			rules:[],
		};
	},
	onLoad() {
	this.getList()
	},
	methods: {
		login() {
			login(this.form).then(res => {
				if(res.data.code==200){
					uni.setStorageSync("token",res.data.token)	
										
										
					uni.switchTab({
						url: '/pages/index/index',
						fail(err) {
							console.log('redirect failed======:', err)
						}
					})
				}else{
					this.showModal(res.msg);
				}
				})
				.catch(err => {
					
				});
			
			
		}

		
	}
};
</script>

<style>

</style>
